﻿using System;
using ChiWalker.Dynamics;
using ChiWalker.Settings;
using ChiWalker.Spell;
using ChiWalker.Utilities;
using Styx;
using Styx.Common.Helpers;
using Styx.CommonBot.POI;
using Styx.TreeSharp;

namespace ChiWalker.Routines.Monk
{
    internal class Common
    {
        private static readonly WaitTimer RollDelay = new WaitTimer(TimeSpan.FromSeconds(2));

        [Behavior(BehaviorType.OutOfCombat)]
        [Spec(WoWSpec.MonkBrewmaster)]
        [Spec(WoWSpec.MonkWindwalker)]
        [Spec(WoWSpec.MonkMistweaver)]
        [Spec(WoWSpec.None)]
        [Class(WoWClass.Monk)]
        public static Composite RollRoutine()
        {
            return new PrioritySelector(
                new CastOnSelf(Spell.Roll,
                    ret =>
                        !ChiWalkerSettings.Instance.DisableMovement && ChiWalkerSettings.Instance.Monk.Roll &&
                        RollDelay.IsFinished && !StyxWoW.Me.Mounted && StyxWoW.Me.IsMoving &&
                        !StyxWoW.Me.IsCasting &&
                        BotPoi.Current.Type != PoiType.Loot && BotPoi.Current.Type != PoiType.Harvest &&
                        BotPoi.Current.Type != PoiType.QuestPickUp
                        && BotPoi.Current.Type != PoiType.QuestTurnIn,
                    ret => RollDelay.Reset())
                );
        }
    }
}